package yesjava;

import java.sql.Connection;

public class Main {
    public static void main(String[] args) throws Exception {
        //List<User> userList = new ArrayList<>();
//        Connection connection = MyDbUtil.getConnection();

        new Thread(() -> {
            System.out.println(Thread.currentThread().getName() + ":-> " + MyDbUtil.getConnection());
            System.out.println(Thread.currentThread().getName() + ":-> " + MyDbUtil.getConnection());
            System.out.println(Thread.currentThread().getName() + ":-> " + MyDbUtil.getConnection());
            System.out.println(Thread.currentThread().getName() + ":-> " + MyDbUtil.getConnection());
            MyDbUtil.closeConnection();
            System.out.println(Thread.currentThread().getName() + ":-> " + MyDbUtil.getConnection());
            System.out.println(Thread.currentThread().getName() + ":-> " + MyDbUtil.getConnection());
        }, "线程1").start();

       /* new Thread(() -> {
            System.out.println(Thread.currentThread().getName()+":-> "+MyDbUtil.getConnection());
            System.out.println(Thread.currentThread().getName()+":-> "+MyDbUtil.getConnection());
        },"线程2").start();*/


        Connection connection = MyDbUtil.getConnection();
        connection.close();

//        3. 通过数据库连接（connection）获取  statement 对象
//        4. 执行SQL 语句
//        5. 处理结果
//        6. 关闭资源
    }
}
